﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class YiGongBaoMing : System.Web.UI.PageEx
{
    private DataSet ds = null;
    public static int iSelectId = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        int.TryParse(Convert.ToString(Request.QueryString["Id"]), out iSelectId);
        if (!Page.IsPostBack)
        {
            DataBinds();
        }
    }
    private void DataBinds()
    {
        ds = DalEx.DbCompInfoEx.Select(" and cStatus=1");
        rptType.DataSource = ds;
        rptType.DataBind();

        Model.DbArticles M_DbArticles = Dal.DbArticlesDal.Select(iSelectId);
        if (M_DbArticles != null)
        {
            lblSubTitle.Text = lblShowTitle.Text = M_DbArticles.ATitle;
            litShowInfo.Text = HttpUtility.HtmlDecode(M_DbArticles.ANote);
            lblEndDate.Text = "报名截止时间：" + M_DbArticles.CEndDate.ToShortDateString();
            lblEndDate.Visible = M_DbArticles.CEndDate.CompareTo(DateTime.Now) >= 0;
            pnlLinkSign.Visible = M_DbArticles.CEndDate.CompareTo(DateTime.Now) >= 0 || M_DbArticles.CEndDate.CompareTo(SqlHelper.MinDate) == 0;
            setMeta(M_DbArticles.AHtmlTitle, M_DbArticles.AKeywords, M_DbArticles.ADescription);
        }
    }
    private void setMeta(string title, string key, string des)
    {
        string strWebTitle = string.Empty, strWebKeywords = string.Empty, strWebDescription = string.Empty;
        Model.DbSystem dbSystem = Dal.DbSystemDal.Select(1);
        if (dbSystem != null)
        {
            strWebTitle = dbSystem.STitle;
            strWebKeywords = dbSystem.SKeywords;
            strWebDescription = dbSystem.SDescription;
        }
        HtmlMeta keywords = new HtmlMeta(); // keywords
        HtmlMeta description = new HtmlMeta(); // description
        keywords.Name = "keywords";
        keywords.Content = string.IsNullOrEmpty(key) ? strWebKeywords : key;

        this.Title = string.IsNullOrEmpty(title) ? strWebTitle : title;

        description.Name = "description";
        description.Content = string.IsNullOrEmpty(des) ? strWebDescription : des;

        Page.Header.Controls.Add(keywords);
        Page.Header.Controls.Add(description);
    }
}
